//
//  PopoverPresentationController.m
//  Weibo
//
//  Created by student on 16/4/26.
//  Copyright © 2016年 Mcc. All rights reserved.
//

#import "PopoverPresentationController.h"

@implementation PopoverPresentationController

//布局转场子视图时调用
-(void)containerViewDidLayoutSubviews
{
    // 1. 修改弹出视图的消息
    //    self.presentedView.frame = CGRectMake(100, 50, 200, 200);
    self.presentedView.frame=self.presentFrame;
   
    //在容器视图上添加一个蒙板
    UIView *bgView=[[UIView alloc]init];
    bgView.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.2];
    bgView.frame=[UIScreen mainScreen].bounds;
    [self.containerView insertSubview:bgView atIndex:0];
    
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapDo:)];
    [bgView addGestureRecognizer:tap];
}
-(void)tapDo:(UITapGestureRecognizer *)g
{
    [self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}

@end
